package tt.dz.appserver.dao.ext;

import java.util.ArrayList;
import java.util.List;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import tt.dz.appserver.dao.base.BasisDao;
import tt.dz.appserver.entity.model.pub.Shares;
import tt.dz.appserver.entity.model.push.PushMessage;
import tt.dz.appserver.util.Constants;

@Repository
public class PushMessageDao extends BasisDao<PushMessage> {

	/**
	 * 消息列表
	 * 
	 * @param pageNo
	 * @return
	 */
	@Cacheable(value="pushMessage",key="'pageNo'+#pageNo")
	public List<PushMessage> findList(PushMessage message, Integer pageNo) {
		message.setValid_flag(1);
		return super.findExample(message, pageNo, Constants.PAGE_SIZE, "edit_date", 0);
	}


	/**
	 * 保存消息
	 * @param share
	 * @return
	 */
	@CacheEvict(value="pushMessage",allEntries=true)
	public int save(PushMessage obj) {
		return super.save(obj);
	}
	/**
	 * 更新消息
	 */
	@CacheEvict(value="pushMessage",allEntries=true)
	public int update(PushMessage obj) {
		return super.update(obj);
	}
	

	/**
	 * 逻辑删除
	 */
	@CacheEvict(value="pushMessage",allEntries=true)
	public int LogicDelete(PushMessage obj) {
		return super.LogicDelete(obj);
	}
	/**
	 * 获取详细
	 * @param shareId
	 * @return
	 */
	@Cacheable(value="pushMessage",key="'push_id'+#push_id")
	public PushMessage findSharesDetailByPushId(String push_id){

		PushMessage messge = new PushMessage();
		messge.setValid_flag(1);
		messge.setPush_id(push_id);
		List<PushMessage> list = super.findExample(messge);
		
		if(list.size()>0){
			return list.get(0);
		}
		return null;
	}
	
	public Integer number(){

		PushMessage messge = new PushMessage();
		messge.setValid_flag(1);
		List<PushMessage> list = new ArrayList<PushMessage>();
		list = super.findExample(messge);

		return list.size();
	}
	
}




